function checkall(obj_chk){
//	document.forms(0).chk_recordtype[0].onclick();
	for (var i=0;i<obj_chk.length;i++){
		obj_chk[i].checked = true;
		document.all.tr_recordtype[i].checked = "checked";
	}
	if (document.all.rad_recordtype[1].checked){
		show_row_all('rad_recordtype','tr_recordtype');
	}
}
function decheckall(obj_chk){
	for (var i=0; i<obj_chk.length;i++){
		obj_chk[i].checked = false;
		document.all.tr_recordtype[i].checked = "";
	}
	if (document.all.rad_recordtype[1].checked){
		show_row_selected('rad_recordtype','tr_recordtype');
	}
}
/////Begin/////Cac ham phuc vui cho checkbox multiple
function show_row_selected(rad_id,tr_name){
	//Thay doi selected cua radio button
	eval('document.all.' + rad_id + '(0).checked=false');
	eval('document.all.' + rad_id + '(1).checked=true');
	//hide cac dong chua modul neu tr_name='tr_function' va gia tri cua checked=""
	if (tr_name == 'tr_function'){
		v_count=eval('document.all.tr_modul.length');
		if (v_count){
			for(var i=0;i<v_count;i++){
				if (eval('document.all.tr_modul[i].checked == ""')){
					eval('document.all.tr_modul[i].style.display="none"');
				}else{
					eval('document.all.tr_modul[i].style.display="block"');
				}
			}
		}else{
			if (eval('document.all.tr_modul.checked == ""')){
				eval('document.all.tr_modul.style.display="none"');
			}else{
				eval('document.all.tr_modul.style.display="block"');
			}
		}
	}
	//hide cac dong tr_name neu gia tri checked=""
	v_count=eval('document.all.' + tr_name + '.length');
	var v_odd_class="";
	if(v_count){
		for(var i=0;i<v_count;i++){
			if (eval('document.all.' + tr_name + '[i].checked == ""')){
				eval('document.all.' + tr_name + '[i].style.display="none"');
			}else{
				if (v_odd_class == "odd_row"){
					eval('document.all.'+ tr_name + '[i].className="round_row"');
					v_odd_class = "round_row"
				}else{
					eval('document.all.'+ tr_name + '[i].className="odd_row"');
					v_odd_class = "odd_row"
				}
			}
		}
	}else{
		if (eval('document.all.' + tr_name + '.checked == ""')){
			eval('document.all.' + tr_name + '.style.display="none"');
		}else{
			if (v_odd_class == "odd_row"){
				eval('document.all.'+ tr_name + '.className="round_row"');
				v_odd_class = "round_row"
			}else{
				eval('document.all.'+ tr_name + '.className="odd_row"');
				v_odd_class = "odd_row"
			}
		}
	}
}
//Ham show_all_row co chuc nang hien thi tat ca doi tuong (ke ca khong thuoc nhom)
function show_row_all(rad_id,tr_name){
	//Thay doi selected cua radio button
	eval('document.all.' + rad_id + '(0).checked=true');
	eval('document.all.' + rad_id + '(1).checked=false');
	//show tat ca cac tr_modul neu tr_name='tr_function'
	if (tr_name == 'tr_function'){
		v_count=eval('document.all.tr_modul.length');
		if(v_count){
			for(var i=0;i<v_count;i++){
				var v_img_path = getImgDirectory(eval('document.all.img_modul[i].src'));
				eval('document.all.img_modul[i].src = v_img_path + "open.gif"');
				eval('document.all.tr_modul[i].style.display="block"');
			}
		}else{
			eval('document.all.tr_modul.style.display="block"');
		}
	}
	//show tat ca cac tr_name
	v_count=eval('document.all.' + tr_name + '.length');
	var v_odd_class="";
	if(v_count){
		for(var i=0;i<v_count;i++){
			eval('document.all.' + tr_name + '[i].style.display="block"');
			if (v_odd_class == "odd_row"){
				eval('document.all.'+ tr_name + '[i].className="round_row"');
				v_odd_class = "round_row"
			}else{
				eval('document.all.'+ tr_name + '[i].className="odd_row"');
				v_odd_class = "odd_row"
			}
		}
	}else{
		eval('document.all.' + tr_name + '.style.display="block"');
		if (v_odd_class == "odd_row"){
			eval('document.all.'+ tr_name + '.className="round_row"');
			v_odd_class = "round_row"
		}else{
			eval('document.all.'+ tr_name + '.className="odd_row"');
			v_odd_class = "odd_row"
		}
	}
}
/*Ham change_item_checked
Chuc nang: Xu ly khi NSD click mouse vao checkbox cua EndUser hoac cua Function
	-Tim tr_name chua checkbox duoc click va thay doi trang thai cua attribute checked ("" hoac "checked")
	-Kiem tra cac trang thai checked cua cac function trong modul de xac dinh trang thai checked cua modul
	(Neu khong co function nao duoc chon thi checked=""; neu co thi checked="checked")
	-Kiem tra che do hien thi (qua radio button) de refresh lai man hinh
Tham so:
	-chk_obj: doi tuong checkbox duoc click
	-tr_name: ten id cua row chua checkbox (tr_function hoac tr_enduser)
	-rad_id:  ten id cua radio button xac dinh che do hien thi cua moi loai (rad_group_enduser hoac rad_group_function)
*/
function change_item_checked(chk_obj,tr_name,rad_id){
	var v_count;
	var i;
	var v_modul_checked=false;
	//Tim row chua checkbox va thay doi gia tri cua tr_name.checked
	v_count = eval('document.all.' + tr_name +'.length');
	i=0;
	if (v_count){
		while (i<v_count){
			if (eval('document.all.' + tr_name + '[i].value == chk_obj.value')){
				if (eval('document.all.' + tr_name + '[i].checked == "checked"')){
					eval('document.all.' + tr_name + '[i].checked = ""');
				}else{
					eval('document.all.' + tr_name + '[i].checked = "checked"');
				}
				//break;
			}
			//Kiem tra xem trong mo dul co chuc nang nao duoc chon khong
			if (tr_name == 'tr_function'){
				if (eval('document.all.' + tr_name + '[i].modul == chk_obj.modul')){
					if (eval('document.all.' + tr_name + '[i].checked == "checked"')){
						v_modul_checked=true;
					}
				}
			}
			i++;
		}
	}else{
		if (eval('document.all.' + tr_name + '.value == chk_obj.value')){
			if (eval('document.all.' + tr_name + '.checked == "checked"')){
				eval('document.all.' + tr_name + '.checked = ""');
			}else{
				eval('document.all.' + tr_name + '.checked = "checked"');
			}
		}
		if (tr_name == 'tr_function'){
			if (eval('document.all.' + tr_name + '.modul == chk_obj.modul')){
				if (eval('document.all.' + tr_name + '.checked == "checked"')){
					v_modul_checked=true;
				}
			}
		}
	}
	//thay doi gia tri cua checked trong tr_modul va chk_modul_id theo v_modul_checked=True or False
	if (tr_name == 'tr_function'){
		v_count = eval('document.all.tr_modul.length');
		if (v_count){
			i=0;
			while (i<v_count){
				if (eval('document.all.tr_modul[i].value == chk_obj.modul')){
					if (v_modul_checked == true){
						eval('document.all.tr_modul[i].checked = "checked"');
						eval('document.all.chk_modul_id[i].checked = "checked"');
					}else{
						eval('document.all.tr_modul[i].checked = ""');
						eval('document.all.chk_modul_id[i].checked = ""');
					}
					break;
				}
				i++;
			}
		}else{
			if (eval('document.all.tr_modul.value == chk_obj.modul')){
				if (v_modul_checked == true){
					eval('document.all.tr_modul.checked = "checked"');
				}else{
					eval('document.all.tr_modul.checked = ""');
				}
			}
		}
	}
	//Kiem tra che do hien thi de refresh man hinh
	if (eval('document.all.' + rad_id + '(1).checked')){
		show_row_selected(rad_id,tr_name);
	}
}


function sel_onclick(p_select_obj,p_hidden_obj) {
	p_hidden_obj.value = p_select_obj.value ;
}
function btn_save_worktype_onclick(p_recordtype_checkbox_obj,p_hdn_recordtype_checkbox_obj,p_fuseaction){
	p_hdn_recordtype_checkbox_obj.value = checkbox_value_to_list(p_recordtype_checkbox_obj,"!&~$*");
	btn_save_onclick(p_fuseaction);
}
// begin nieuvv-180608--- 
function btn_save_worktype_recordtype_onclick(p_recordtype_checkbox_obj,p_recordtype_textbox_obj,p_hdn_recordtype_checkbox_obj,p_hdn_number_id_list,p_fuseaction){
	p_hdn_recordtype_checkbox_obj.value = checkbox_value_to_list(p_recordtype_checkbox_obj,"!&~$*");
	p_hdn_number_id_list.value = textbox_value_to_list(p_recordtype_checkbox_obj,p_recordtype_textbox_obj,"!&~$*");
	//alert(p_hdn_recordtype_checkbox_obj.value);
	//alert(p_hdn_number_id_list.value);
	//return;
	//p_fuseaction.value = p_hdn_number_id_list.value;	
	btn_save_onclick(p_fuseaction);	
}
// the end nieuvv - 180608